{% extends 'website/frontend_base.html' %}

{% block title %}加入我们{% endblock %}

{% block external_head %}{% endblock %}


{% block left %}
    <div class="col-md-12">
        <h3 class="text-center text-info">加入我们</h3>
        <div class="col-md-6 col-md-offset-3">
            <form class="form-horizontal" method="post" id="data-form" enctype="multipart/form-data">
                {% csrf_token %}
                <div class="form-group">
                    <label for="username" class="col-sm-3 control-label">用户名:</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" id="username" name="username" required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="password" class="col-sm-3 control-label">密码:</label>
                    <div class="col-sm-9">
                        <input type="password" class="form-control" id="password" name="password" required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="repeat-password" class="col-sm-3 control-label">重复密码:</label>
                    <div class="col-sm-9">
                        <input type="password" class="form-control" id="repeat-password" name="repeat-password" required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="name" class="col-sm-3 control-label">姓名:</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" id="name" name="name" required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="student_id" class="col-sm-3 control-label">学号:</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" id="student_id" name="student_id" required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="college" class="col-sm-3 control-label">学院:</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" id="college" name="college" required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="level" class="col-sm-3 control-label">入学年份:</label>
                    <div class="col-sm-9">
                        <input type="number" class="form-control" id="level" name="level" required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="sex" class="col-sm-3 control-label">性别:</label>
                    <div class="col-sm-9">
                        <div class="radio">
                            <label>
                                <input type="radio" name="sex" value="M" checked>
                                男
                            </label>
                            <label>
                                <input type="radio" name="sex" value="F">
                                女
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="birthday" class="col-sm-3 control-label">生日:</label>
                    <div class="col-sm-9">
                        <input type="date" class="form-control" id="birthday" name="birthday">
                    </div>
                </div>
                <div class="form-group">
                    <label for="email" class="col-sm-3 control-label">E-mail:</label>
                    <div class="col-sm-9">
                        <input type="email" class="form-control" id="email" name="email" required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="tel" class="col-sm-3 control-label">电话:</label>
                    <div class="col-sm-9">
                        <input type="tel" class="form-control" id="tel" name="tel" required>
                        <div class="radio">
                            <label>
                                <input type="radio" name="is_public_tel" value="True" checked>
                                对社内公开
                            </label>
                            <label>
                                <input type="radio" name="is_public_tel" value="">
                                不公开（仅管理员可见）
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="qq" class="col-sm-3 control-label">QQ:</label>
                    <div class="col-sm-9">
                        <input type="number" class="form-control" id="qq" name="qq">
                        <div class="radio">
                            <label>
                                <input type="radio" name="is_public_qq" value="True" checked>
                                对社内公开
                            </label>
                            <label>
                                <input type="radio" name="is_public_qq" value="">
                                不公开（仅管理员可见）
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="description" class="col-sm-3 control-label">个人简介：</label>
                    <div class="col-sm-9">
                        <textarea name="description" id="description" rows="5" wrap="hard" class="col-md-12 form-control"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="photo" class="col-sm-3 control-label">头像:</label>
                    <div class="col-sm-9">
                        <input type="file" class="form-control" id="photo" name="photo" required>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-3 col-sm-3">
                        <button type="button" class="btn btn-primary" id="submit-btn">提交</button>
                    </div>
                    <div class="col-sm-offset-3 col-sm-3">
                        <button type="reset" class="btn btn-warning">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    {% include 'utils/modal.html' %}
{% endblock %}


{% block js %}
    <script type="text/javascript">
        var password = $('#password');
        var repeat_password = $('#repeat-password');
        $('#submit-btn').on('click', function(e) {
            e.preventDefault();
            if (password.val() == repeat_password.val()) {
                $('#data-form').submit();
            } else {
                showModal('danger', "密码不匹配，请重新输入");
            }
        })
    </script>
{% endblock %}